@import "func";

@mixin text-overflow ($width: 100%, $display: block) {
  display: $display;
  width: $width;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}


@mixin clearfix {
  *zoom: 1;
  *height: 1%;
  &:after {
    clear: both;
    content: '.';
    display: block;
    height: 0;
    line-height: 0;
    overflow: hidden;
  }
}

@mixin flexBox($direction: null) {
  display: flex;
  @if ($direction != null) {
    flex-direction: $direction;
  }
}

@mixin flexRow($justify: null, $align: null, $flex-wrap: null) {
  @include flexBox(row);
  @if ($justify != null) {
    justify-content: $justify;
  }
  @if ($align != null) {
    align-items: $align;
  }
  @if ($flex-wrap != null) {
    flex-wrap: $flex-wrap;
  }
}

@mixin flexColumn($justify: null, $align: null, $flex-wrap: null) {
  @include flexBox(column);
  @if ($justify != null) {
    justify-content: $justify;
  }
  @if ($align != null) {
    align-items: $align;
  }
  @if ($flex-wrap != null) {
    flex-wrap: $flex-wrap;
  }
}

@mixin flexCenter($direction: null, $flex-wrap: null) {
  @include flexBox($direction);
  justify-content: center;
  align-items: center;
  @if ($flex-wrap != null) {
    flex-wrap: $flex-wrap;
  }
}

@mixin flex-column ($length)
{
  @for $index from 1 through $length
  {
    .flex-#{$index}
    {
      flex: $index;
    }
  }
}

@mixin span ($length, $i: null)
{
  @for $index from 1 through $length {
    $gutter: $length / $index;

    @if ($i == null) {
      .col-#{$index} {
        width: float($length, $index) * 1%;

        @if (floor($gutter) == $gutter) {
          &:nth-child(#{$length / $index}) {
            padding-right: 0;
          }
        }
      }
    } @else {
      .col-#{$i}-#{$index} {
        width: float($length, $index) * 1%;

        @if (floor($gutter) == $gutter) {
          &:nth-child(#{$length / $index}) {
            padding-right: 0;
          }
        }
      }
    }

  }
}

@mixin positionAbsolute($top: null, $right: null, $bottom: null, $left: null) {
  position: absolute;
  @if ($left != null) {
    left: $left;
  }
  @if ($right != null) {
    right: $right;
  }
  @if ($top != null) {
    top: $top;
  }
  @if ($bottom != null) {
    bottom: $bottom;
  }
}

@mixin line-height($height:30px,$line-height:30px) {
  @if ($height != null) {
    height: $height;
  }
  @if ($line-height!=null) {
    line-height: $line-height;
  }
}

// 固定定位, 兼容IE6
@mixin fixed {
  position: fixed;
  _position: absolute;
  *zoom: 1;
}

// 尺寸
@mixin size($w, $h) {
  width: $w;
  height: $h;
}

// 最小尺寸, 兼容IE6
@mixin min-width($min-w) {
  min-width: $min-w;
  _width: $min-w;
}

@mixin min-height($min-h) {
  min-height: $min-h;
  _height: $min-h;
}
